package edu.xidian.bdilab.jrbigdata.controller.bank;

import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.service.bank.bankInfo.BankInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@Api(tags = {"BankInfo-处理金融机构信息"})
public class BankInfoController {
    @Autowired
    BankInfoService bankInfoService;

    @ResponseBody
    @ApiOperation("获取所有金融机构信息")
    @RequestMapping(value = "bank/getAllBankInformation", method = RequestMethod.POST)
    public ResponseResult getAllBankInformation(@RequestParam(defaultValue = "1")@ApiParam(value = "页码") int pageNum,
                                                @RequestParam(defaultValue = "10")@ApiParam(value = "每页记录数") int pageSize,
                                                @RequestParam(required = false) @ApiParam(value = "金融机构名称（支持模糊查询）") String bankName,
                                                @RequestParam(required = false) @ApiParam(value = "所属区域（支持模糊查询）") String region,
                                                @RequestParam(required = false) @ApiParam(value = "所属街道/乡镇（支持模糊查询）") String street,
                                                @RequestParam(required = false) @ApiParam(value = "金融机构详情（支持模糊查询）") String description
                                             )throws Exception{
        ResponseResult responseResult=bankInfoService.getAllBankInfo(pageNum,pageSize,bankName,region,street,description);
        return responseResult;
    }

    @ResponseBody
    @ApiOperation("查询金融机构信息")
    @RequestMapping(value = "bank/getBankInformationByID", method = RequestMethod.GET)
    public ResponseResult getBankInformationByID(@RequestParam(required = false) @ApiParam(value = "金融机构id") int bankID
    )throws Exception{
        ResponseResult responseResult=bankInfoService.getBankInformationByID(bankID);
        return responseResult;
    }


    @ResponseBody
    @ApiOperation("修改金融机构（银行）信息")
    @RequestMapping(value = "bank/modifyBankInformation", method = RequestMethod.POST)
    public ResponseResult modifyBankInformation(@RequestParam String bankName,
                                                @RequestParam int regin,
                                                @RequestParam String street,
                                                @RequestParam String contactName,
                                                @RequestParam String contactPhone,
                                                @RequestParam String description
                                                )throws Exception{
        ResponseResult responseResult=bankInfoService.modifyBankInformation(bankName,regin,street,contactName,contactPhone,description);
        return responseResult;
    }
}
